using System.Collections.Generic;
using UnityEngine;
namespace DefaultNamespace.Skill
{
    public class BuffData
    {
        public string id;
        public float amount;
        public float duration;
        public float StartTime { get; set; }
        public float EndTime { get; set; }
        
        public BuffData(string id, float amount, float duration)
        {
            this.id = id;
            this.amount = amount;
            this.duration = duration;
        }
    }
    public class BuffSystem : MonoBehaviour
    {
        private Dictionary<string, BuffData> activeBuffs = new Dictionary<string, BuffData>();
        public void ApplyBuff(BuffData buff)
        {
            if (activeBuffs.ContainsKey(buff.id))
            {
                activeBuffs[buff.id].EndTime = Time.time + buff.duration;
            } else
            {
                buff.StartTime = Time.time;
                buff.EndTime = Time.time + buff.duration;
                activeBuffs.Add(buff.id, buff);
                ApplyBuffEffects(buff);
            }
        }
        private void Update()
        {
            List<string> toRemove = new List<string>();
            foreach (var kvp in activeBuffs)
            {
                if (Time.time >= kvp.Value.EndTime)
                {
                    RemoveBuffEffects(kvp.Value);
                    toRemove.Add(kvp.Key);
                }
            }
            foreach (var key in toRemove)
            {
                activeBuffs.Remove(key);
            }
        }
        private void ApplyBuffEffects(BuffData buff)
        {
            // Apply effects based on buff type
        }
        private void RemoveBuffEffects(BuffData buff)
        {
            // Remove effects based on buff type
        }
    }
}